package com.yyplatform.frontend.infra.model;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort.Direction;

import lombok.Data;

/**
 * Created on 2024-09-13
 */
@Data
public class PageQueryDTO {
    private Integer pageNum;
    private Integer pageSize;


    public PageRequest getPageRequest() {
        return PageRequest.of(pageNum - 1, pageSize);
    }

    public PageRequest getPageRequestOrderByIdDesc() {
        return PageRequest.of(pageNum - 1, pageSize).withSort(Direction.DESC, "id");
    }

    public PageRequest getPageRequestOrderByOrderNumDesc() {
        return PageRequest.of(pageNum - 1, pageSize).withSort(Direction.DESC, "order_num")
                .withSort(Direction.DESC, "id");
    }

}
